<?php

class Core_Data_UDD_Structure_Field {

    private $Table;

    private $strName;
    private $constDataType;
    private $constKeyType;
    private $boolRequired = false;
    private $intSize = null;

    function __construct ( Core_Data_UDD_Structure_Table $objTable, $strName, $constDataType ) {
        $this->Table = $objTable;
        $this->strName = $strName;
        $this->constDataType = $constDataType;
    }

    function __toString () {
        return (string) $this->strName;
    }

    public function getDataType () {
        return $this->constDataType;
    }

    public function isKey () {
        return ( $this->constKeyType ) ? true : false;
    }

    public function setKey ( $constKeyType = Core_Data_UDD_KeyTypes::UNIQUE ) {
        $this->constKeyType = $constKeyType;
    }

    public function getKeyType () {
        return $this->constKeyType;
    }

    public function isRequired () {
        return $this->boolRequired;
    }

    public function setRequired () {
        $this->boolRequired = true;
    }

    public function getSize () {
        return $this->intSize;
    }

    public function setSize ( $intSize ) {
        // TODO: Throw an exception if if the data type is not text.
        // TODO: Ensure that $intSize is an integer above 0.
        $this->intSize = $intSize;
    }

}

?>
